package com.fly.domain;


import com.fly.persistence.DataEntity;

import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.util.ArrayList;
import java.util.List;


/**
 * @author Fly
 * @Description 部门管理
 * @Date Created in 15:20 2018/1/25
 * @Modified by
 */
@Entity
@Table(name = "sys_department")
public class Department extends DataEntity<Department>{

    /**
     * 部门名称
     */
    @NotNull(message = "部门名称不能为空")
    @Column(unique = true)
    @Size(min = 2,max = 3)
    private String name;

    @Transient
    private List<Department> children = new ArrayList<>();

    private Long parentId;

    public void setParentId(Long parentId) {
        this.parentId = parentId;
    }

    public Long getParentId() {
        return parentId;
    }

    public List<Department> getChildren() {
        return children;
    }

    public void setChildren(List<Department> children) {
        this.children = children;
    }

    public String getTitle() {
        return name;
    }

    public String getLabel() {
        return name;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }


    @Override
    public String toString() {
        return "Department{" +
                "name='" + name + '\'' +
                ", parentId=" + parentId +
                ", id=" + id +
                '}';
    }
}
